﻿@{
    Layout = "_Layout.cshtml";
}
@using WebApp.Models
@using WebApp.Extensions
@using Telerik.Web.Mvc.UI
@model IEnumerable<REL_Piatto_Ingrediente>
@{
    ViewBag.Title = "Composizione dei piatti";
    String ptt = (String)ViewData["ptt"];
    String fml = (String)ViewData["fml"];
}
@(Html.Telerik().Grid(Model)
        .Name("Grid")
        .ToolBar(commands =>
            {
                commands.Insert();
                commands.Custom().Action("FAM_PIA_LST", "Setup", new { f0 = fml }).Text("Piatto");
            })
        .DataKeys(keys => keys.Add(c => c.Guid))
        .HtmlAttributes(new { @class = "data" })
        .Columns(columns =>
        {
            columns.Bound(o => o.ENT_Ingrediente.Nome).Sortable(true).Title("Ingrediente");
            columns.Bound(o => o.Prezzo).Format("{0:C2}").Title("Prezzo").Width(80);
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.Image);
                commands.Delete().ButtonType(GridButtonType.Image);
            }).Width(100);
        })
        .Editable(editing => editing.Mode(GridEditMode.PopUp))
        .DataBinding(dataBinding => dataBinding
            .Server()
               .Select("PIA_ING_LST", "Setup", new { f0 = ptt })
               .Insert("PIA_ING_INS", "Setup", new { f0 = ptt })
               .Update("PIA_ING_SAV", "Setup", new { f0 = ptt })
               .Delete("PIA_ING_DEL", "Setup", new { f0 = ptt }))
)
